import { useDispatch } from 'react-redux';
import { ReduxDispatch } from '@/mySliceCreator.ts';
import {
  asyncSlice,
  AsyncSliceType,
  useAsyncSliceDispatch,
} from '@/ModuleOne/slice.ts';
import { defaultSlice, useAppDispatch } from '@/Provider.tsx';

const useTestDispatchTypes = () => {
  const dispatch = useDispatch<ReduxDispatch<AsyncSliceType>>();
  const dispatch1 = useDispatch.withTypes<ReduxDispatch<AsyncSliceType>>()();
  const dispatchIncrement = useAsyncSliceDispatch();
  const strictDispatch = useAppDispatch();

  // Проверка типизации диспатчера
  dispatch(defaultSlice.actions.setTemp(1)); //
  dispatchIncrement(defaultSlice.actions.setTemp(1));
  dispatchIncrement(asyncSlice.actions.increment());
  dispatch(defaultSlice.actions.setTemp(1));
  dispatch1(defaultSlice.actions.setTemp(1));

  strictDispatch(asyncSlice.actions.increment());
};
